<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function myAxios(){
      let pA=new Promise ((resolve,reject)=>{
        setInterval(()=>{
          reject('失败')
        },2000)
      })
      return pA
    }
    let pA=myAxios()

    let pB = pA.then(res=>{
      return [null,res]
    }).catch(err=>{
      return [err,null]
    })
    async function myFn(){
      const [err,res]=await pB
      if (err) console.error(err);
      else console.log(res);
    }
    myFn()
  </script>
</body>
</html>